package com.zzw.hj90;

import java.util.Objects;
import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 合法IP
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static boolean isLegalIp(String ip) {
        String[] s = ip.split("\\.");
        // 判断ip是否由四部分组成
        if (s.length != 4) {
            return false;
        }
        for (int i = 0; i < 4; i++) {
            if (Objects.equals(s[i], "")) {
                return false;
            }
            if (Integer.parseInt(s[i]) < 0 || Integer.parseInt(s[i]) > 255) {
                return false;
            }
            char[] chars = s[i].toCharArray();
            if (chars.length > 1 && chars[0] == '0') {
                return false;
            }
            for (char aChar : chars) {
                if (aChar < '0' || aChar > '9') {
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String ip = in.nextLine();
        System.out.println(isLegalIp(ip) ? "YES" : "NO");
    }
}